﻿using System;
using System.Diagnostics.Contracts;
using System.Reflection;
using Beaker.Injection;

namespace OpenCube.Nbt.Mapping
{
	/// <summary>
	/// The context of the conversion. It can provide you with more information about the conversion, for example, the property.
	/// </summary>
	[ContractClass(typeof(ConversionContextContract))]
	public interface IConversionContext
	{
		/// <summary>
		/// Gets the query container so you have access to DI
		/// </summary>
		IQueryContainer QueryContainer { get; }

		/// <summary>
		/// Gets the member info that provides you with property or class being convert to/from
		/// </summary>
		MemberInfo MemberInfo { get; }

		/// <summary>
		/// Gets the NBT dictionary holding the source/target NBT key value store.
		/// </summary>
		INbtDictionary NbtDictionary { get; }
	}

	[ContractClassFor(typeof(IConversionContext))]
	abstract class ConversionContextContract
		: IConversionContext
	{
		public IQueryContainer QueryContainer
		{
			get
			{
				Contract.Ensures(Contract.Result<IQueryContainer>() != null);
				throw new NotImplementedException();
			}
		}

		MemberInfo IConversionContext.MemberInfo
		{
			get { throw new NotImplementedException(); }
		}

		public INbtDictionary NbtDictionary
		{
			get { throw new NotImplementedException(); }
		}
	}
}